﻿using System;
using System.Windows.Printing;

namespace MyFloridaHouse.libSvOpenDistricts.ViewModel
{
    public partial class ViewModelBase
    {
        #region properties
        private bool _isPrintMapActive = false;
        public bool isPrintMapActive
        {
            get { return _isPrintMapActive; }
            set
            {
                if (_isPrintMapActive != value)
                {
                    _isPrintMapActive = value;
                    NotifyPropertyChanged("isPrintMapActive");
                }
            }
        }
        #endregion

        #region Commands

        #region Print Map
        private bool CmdPrintMapCanExecute(object parameter)
        {
            return true;
        }

        private void CmdPrintMapExecute(object parameter)
        {
            PrintMap();
        }


        public void PrintMap()
        {
            isPrintMapActive = true;
        }

        public void PrintMapOK()
        {
            isPrintMapActive = false;
        }

        public void PrintMapCancel()
        {
            isPrintMapActive = false;
        }

        #endregion

        #region Print Map Cancel
        private bool CmdPrintMapCancelCanExecute(object parameter)
        {
            return true;
        }

        private void CmdPrintMapCancelExecute(object parameter)
        {
            PrintMapCancel();
        }
        #endregion

        #region File Print OK
        private bool CmdPrintMapOKCanExecute(object parameter)
        {
            return true;
        }

        private void CmdPrintMapOKExecute(object parameter)
        {

            // Create new a new PrintDocument object
            PrintDocument pd = new PrintDocument();

            // Set the printable area
            pd.PrintPage += (s, args) =>
            {
                args.PageVisual = this.myXamlMainMap;
            };

            // Print the document
            pd.Print("MyDistrictBuilderPrintMap");
            isPrintMapActive = false;
        }
        #endregion

        #endregion

    }
}

